package com.frank.libandroid.util;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;

import com.bumptech.glide.Glide;

public class ImageUtil {
    public static String Host = "";

    @BindingAdapter("circleUrl")
    public static void loadCircle(ImageView imageView, String circleUrl) {
        if (TextUtils.isEmpty(circleUrl)) {
            return;
        }
        Glide.with(imageView.getContext()).load(circleUrl).circleCrop().into(imageView);
    }

    public static void loadUrl(ImageView imageView, String circleUrl) {
        if (TextUtils.isEmpty(circleUrl)) {
            return;
        }
        Glide.with(imageView.getContext()).load(circleUrl).into(imageView);
    }

    @BindingAdapter("url")
    public static void load(ImageView imageView, String circleUrl) {
        if (TextUtils.isEmpty(circleUrl)) {
            return;
        }
        Glide.with(imageView.getContext()).load(circleUrl).into(imageView);
    }

    @BindingAdapter("resId")
    public static void loadImage(ImageView imageView, int resId) {
        Glide.with(imageView.getContext()).load(resId).into(imageView);
    }


}
